package mlz.c_map;

import java.util.HashMap;
import java.util.function.BiConsumer;

//default void	forEach(BiConsumer<? super K,? super V> action)	 进行遍历
public class MapDemo05 {
    public static void main(String[] args) {
        HashMap<String,Double> map = new HashMap<>();
        map.put("蜘蛛精",162.8);
        map.put("蜘蛛精",161.8);
        map.put("紫霞仙子",162.8);
        map.put("至尊宝",178.8);
        map.put("牛魔王",190.8);
        map.put("牛夫人",162.8);
        System.out.println(map);

        //进行遍历操作
        map.forEach(new BiConsumer<String, Double>() {
            @Override
            public void accept(String s, Double aDouble) {
                System.out.println("key:" + s + "+ value: " + aDouble);
            }
        });
        System.out.println("-------------------------");

        //Lambda优化写法
        map.forEach((s,d) -> System.out.println("key:" + s + "+ value: " + d));

    }
}
